<? 
require_once("Clases/Alumno.php");
require_once("Clases/Docente.php");
require_once("Clases/Reporte.php");
include "Controladores/validaSesion.php";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>SRP | Reportes</title>
		<link href="css/styles_director2.css" rel="stylesheet" type="text/css" media="all" />
		<link href="font/stylesheet_tutores.css" rel="stylesheet" type="text/css" media="all" />
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery.uniform.js" type="text/javascript" charset="utf-8"></script>
              <script type="text/javascript" src="src/jquery.autocomplete.js"></script>
    <script type="text/javascript" src="scripts/demo.js"></script>
    
   
 
		<script type="text/javascript" charset="utf-8">
                
      $(function(){
        $("input, select").uniform();
      });
    </script>
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    		<link rel="stylesheet" href="css/uniform.defaultstyle3.css" type="text/css" media="screen" />
		<script src="YUI/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js" type="text/javascript"></script>
		<script src="YUI/2.6.0/build/calendar/calendar-min.js" type="text/javascript"></script>
		<script type="text/javascript">
 $(document).ready(function(){
     $('.ddm').hover(
	   function(){
		 $('.ddl').slideDown();
	   },
	   function(){
		 $('.ddl').slideUp();
	   }
	 );
 });
 $(function() { 
        $( "#avanceSemestre" ).dialog({
            autoOpen: false,
            width:1000,
            height:600,
            modal: true,
            buttons: {                
            },
            close: function() {
                    allFields.val( "" ).removeClass( "ui-state-error" );
                }
            });
        });
      $(function() { 
 
        $( "#dialog-form" ).dialog({
            autoOpen: false,
            width:240,
            height:205,
            modal: false,
            buttons: {                
            },
            close: function() {
                    allFields.val( "" ).removeClass( "ui-state-error" );
                }
            });
        });
        $(function() { 
 
        $( "#imagenReporte" ).dialog({
            autoOpen: false,
            width:700,
            height:420,
            modal: true,
            buttons: {                
            },
            close: function() {
                    allFields.val( "" ).removeClass( "ui-state-error" );
                }
            });
        });

        function reportesalumno(id)
        {
            
            var way= "Reportes/porAlumno.php?Matricula="+id;        
            $.ajax({
                'url' : way,'type' : 'GET',
                'success' : function(info) {
                        window.location.href = info;
                    }
                }); 
        }
        
        function reportestodos()
        {
            var id = $('#tutores :selected').val();
            $( "#dialog-form" ).dialog( "open" );
        }
    function clearTable(table)
            {
                var tableRef = document.getElementById(table);
                while ( tableRef.rows.length > 1 )
                    tableRef.deleteRow(1);
                //$('#excelTable > tbody:last').append('<th>Materia</th><th>Profesor</th><th>P1</th><th>P2</th><th>P3</th><th>P4</th><th>FIT</th><th>F1</th><th>F2</th><th>F3</th><th>F4</th><th>Total Faltas</th><th>Limite Faltas</th><th>Estatus</th>');
        }
        function buscarAlumno()
        {
            clearTable("excelTable");
            var search = $('#IdBuscar :selected').val();
            if(search!="Seleccionar Matricula"){
            var status = $('#excelTable');
            var way="Controladores/AlumnoExcel.php?matricula="+search; 
            $.ajax({
                        'url' : way,'type' : 'GET',
                        'success' : function(info) 
                        {
                            var materias = info.split("*");
                            var x = 0;
                            for(x=0;x<materias.length;x++)
                            {
                                var str = "<tr>";
                                var datos = materias[x].split("/");
                                var y = 0;
                                for(y=0;y<datos.length;y++)
                                    str+=('<td>'+datos[y]+'</td>');
                                str+="</tr>";
                                status.append(str);
                            }
                            
                        }
                });
              way= "Controladores/GetAlumno.php?Matricula="+search;        
                            $.ajax({
                                'url' : way,'type' : 'GET',
                                'success' : function(info) {
                                        var nombre = info.split(",");
                                         document.getElementById("nombreAlumno").value = nombre[0];
                                    }
                                }); 
            }
            else alert("Debe Seleccionar una Matricula");
        }
 
      function avanceSemestre()
    {
         $( "#avanceSemestre" ).dialog( "open" );
    }
        function entrada()
        { 
           $("#lst").empty();
           var search = document.getElementById("search").value;
          $("#lst").append("<li> <p class='descripHead'>Alumno</p> <p class='edit'>Ver Historial Reportes </p> <p class='edit'>Estado</p> </li>"); 
            var path= "Controladores/GetAlumnosProfesor.php";        
           $.ajax({
                'url' : path,'type' : 'GET',
                'success' : function(data) {
                      var ar = data.split(",");
                      if(ar.length > 1)
                        for(var x=0; x< ar.length;x++)
                        {
                            var nid = ar[x];
                            var way= "Controladores/GetAlumno.php?Matricula="+ar[x];        
                            $.ajax({
                                'url' : way,'type' : 'GET',
                                'success' : function(info) {
                                        var arr = info.split(",");
                                        var nalumno = arr[0] + " -> " + arr[1];
                                        nid = arr[1];
                                        var algo = startsWith(arr[0],search);
                                        var algo = algo || startsWith(arr[1],search);
                                            if(algo == true){
                                            var id = "<li class=odd id ="+nid + ">";
                                            var Al = "<p class=descrip id=alumnospar>"+nalumno+"</p>";
                                            var icon = arr[2];
                                            if(parseInt(icon)==0)
                                                icon = 0;
                                            else if (parseInt(icon)< 4)
                                                icon = 1;
                                            else 
                                                icon = 2;
                                            icon = getIcono(icon);
                                            var IdR =  "<p class=edit> <a onClick=reportesalumno('"+nid+"') class=pollo><img src=images/icorep.png /></a></p>";
                                            var estado =  "<p class=edit> <img src=images/"+icon +" /></a></p>";
                                            var end = "</li>"; 
                                            var row = id+ Al + IdR + estado + end;
                                            $("#lst").append(row);  
                                        }
                                    }
                                }); 

                        }
                     else if (data != "no")
                     {
                           var way= "Controladores/GetAlumno.php?Matricula="+data;        
                           $.ajax({
                                'url' : way,'type' : 'GET',
                                'success' : function(info) {
                                        var arr = info.split(",");
                                        var nalumno = arr[0] + " -> " + arr[1];
                                        nid = arr[1];
                                        var algo = startsWith(arr[0],search);
                                        var algo = algo || startsWith(arr[1],search);
                                            if(algo == true){
                                            var id = "<li class=odd id ="+nid + ">";
                                            var Al = "<p class=descrip id=alumnospar>"+nalumno+"</p>";
                                            var icon = arr[2];
                                            if(parseInt(icon)==0)
                                                icon = 0;
                                            else if (parseInt(icon)< 4)
                                                icon = 1;
                                            else 
                                                icon = 2;
                                            icon = getIcono(icon);
                                            var IdR =  "<p class=edit> <a onClick=reportesalumno('"+nid+"') class=pollo><img src=images/ver.png /></a></p>";
                                            var estado =  "<p class=edit> <img src=images/"+icon +" /></a></p>";
                                            var end = "</li>"; 
                                            var row = id+ Al + IdR + estado +end;
                                            $("#lst").append(row);  
                                        }
                                    }
                                }); 
                         
                     }
                }
           }); 
           
           
        }
        
     var myVar=setInterval(function(){myTimer()},1000);

        function myTimer()
        {
             $("#topimg").attr("src","Reportes/tutorTopFive.png");
        }
    function getIcono(icono)
        {
            switch(icono)
            {
                case 0:
                    return "icov.png";
                case 1:
                    return "icoa.png";
                case 2:
                    return "icor.png";
            }
        }
         function startsWith(data,str)
        {
            var reg;
            if ((data.length >= str.length && data.substring(0, str.length) == str) || str == "search")
                reg = true;
            else
                reg = false;
            return reg;
        }
        function sleep(milliSeconds){
            var startTime = new Date().getTime(); // get the current time
            while (new Date().getTime() < startTime + milliSeconds); // hog cpu
        }
        function generacion()
        {
            var numero = $('#cantidad :selected').val();
            if(numero == "Todos")
            {
                var way="Controladores/AlumnosGeneracion.php"; 
                 $.ajax({
                    'url' : way,'type' : 'GET',
                    'success' : function(info) {
                             var way="Reportes/tutorTopFive.php?numero="+info; 
                                $.ajax({
                                        'url' : way,'type' : 'GET',
                                        'success' : function(info) {}
                                }); 
                        }
                    }); 
            }
            else{
                var way="Reportes/tutorTopFive.php?numero="+numero; 
                $.ajax({
                        'url' : way,'type' : 'GET',
                        'success' : function(info) {}
                }); 
            }
            $("#topimg").attr("src","Reportes/blank.png");
            $( "#imagenReporte" ).dialog( "open" );
            $( "#dialog-form" ).dialog( "close" );
            sleep(8000);
        }

</script>

          
                
		<script type="text/javascript" src="js/DD_roundies_0.0.2a-min.js"></script>
		<script type="text/javascript">
DD_roundies.addRule('#tabsPanel', '5px 5px 5px 5px', true);

</script>
                <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
                 <script>
    $(function() {
        $( "#FechaInfraccion" ).datepicker();
    });
    $(function() {
	$('#gallery a').lightBox({fixedNavigation:true});
});
        
    </script>
    <script type="text/javascript" src="src/jquery.autocomplete.js"></script>
    <script type="text/javascript" src="scripts/demo.js"></script>
                
		<script type="text/javascript" src="js/script-carasoul.js"></script>
		<link href="YUI/2.6.0/build/fonts/fonts-min.css" rel="stylesheet" type="text/css" />
		<link href="YUI/2.6.0/build/calendar/assets/skins/sam/calendar.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
	$(document).ready(function()
{

   $( '#checkall' ).live( 'click', function() {
				
				$( '.chkl' ).each( function() {
					$( this ).attr( 'checked', $( this ).is( ':checked' ) ? '' : 'checked' );
				}).trigger( 'change' );
 
			});
  $('#checkall').click(function(){


 $('span').toggleClass('checked');
$('#checkall').toggleClass('clicked');

 }); 
	});
		</script>
		</head>
		<input type="hidden" id="escondido" value="0"/>
		<input type="hidden" id="IdReporte" value="0"/>
<div id="admin">
          <div id="wrap">
    <div id="head">
              <h1><a href="inicioTutor.hp">SRP<br />
                <span>Sistema Reportes Preparatoria</span></a></h1>
              <ul id="menu">
                  <li><a href="inicioTutor.php">Inicio</a></li>
                  <li><a href="#">|</a></li>
                  <li><a href="Reportes/reporteTutor.pdf">Ayuda &nbsp;&nbsp;&nbsp;&nbsp;</a></li>
                  <li><a href="#">|</a></li>
                  <li><a href="Controladores/salir.php">Salir</a></li>
              </ul>
              <ul id="tablist">
        <li><a href="#a"><span>Home</span></a></li>
      </ul>
              <div id="tabsPanel">
        <div id="a" class="tab_content">
                  <div class='carousel_container'>
            <div class='left_scroll'><img src='images/leftArrow.png' alt="" /></div>
            <div class='carousel_inner'>
                      <ul class='carousel_ul'>
                <li title="Inicio"><a class="ico4" href='inicioTutor.php'></a></li>
                <li title="Nuevo Reporte"><a class="ico1" href='reporteTutor.php'></a></li>
                <li title="Historial"><a class="ico6" href='historialTutor.php'></a></li>
                <li title="Reportes"><a class="ico2" href='reportesTutor.php'></a></li>
              </ul>
                    </div>
            <div class='right_scroll'><img src='images/rightArrow.png' alt="" /></div>
          </div>
                </div>
        <div id="b" class="tab_content">
                  <div class='carousel_container'>
            <div class='left_scroll2'><img src='images/leftArrow.png' alt="" /></div>
           
            <div class='right_scroll2'><img src='images/rightArrow.png' alt="" /></div>
          </div>
                </div>
        <!--Tab End--> 
      </div>
              <img src="images/shadow.png" class="shadow" alt="" /> </div>
              
    <div id="content">
       <div class="datalist">
           
           <div class="styles">
        <div class="heading">
                  <h2>Reportes Alumnos</h2>
                  
                  <div class="search">
                    <input id="search" onchange="entrada()"  name="search" type="text" value="search" onfocus="if(this.value=='search')this.value=''" onblur="if(this.value=='')this.value='search'" />
                    <input name="" type="submit" value="" />
                </div>
                      </div>
        </div>
       
           
        <ul id="lst">
         
          </ul>
           <div>
               <img style="margin-left: 50px;margin-top:20px" src="images/reportes.png" title="Reportes Alumnos" onClick="reportestodos()"></img>
               </br>
               <img style="margin-left: 50px;margin-top:20px" src="images/avance.png" title="Avance Semestre" onClick="avanceSemestre()"></img>           
           
           </div>
      </div>
              
            
            </div>
  </div>
          <div class="push"></div>
        </div>
<div id="foot">
<p>© SRP</p>      
</div>

 <div id="dialog-form">
    <div class="gradientBoxesWithOuterShadows">
        <h2>Alumnos en el reporte?</h2>
            <select width="120" style="width: 120px" onChange="reportes()" id="cantidad" name="sort">
                <option id="idtodos">
                    Todos
                </option>
                <option id="id5">
                    3
                </option>
                <option id="id10">
                    5
                </option>
                <option id="id15">
                    7
                </option>
            </select> 
        </br>
        </br>
       
    <input name="submit" class="botonc" onClick="generacion();" type="button" value="Aceptar" />
    </div>  
              
 </div>             

<div id="imagenReporte">
    <div>
        <img src="Reportes/tutorTopFive.png" id="topimg" width="600" height ="300" />
    </div>  
              
 </div>             
<div id="avanceSemestre" style="overflow: auto" >
    <div>
        <select id="IdBuscar" onChange="buscarAlumno()">
            <option>Seleccionar Matricula</option>
            <?
        
        
        $list = $docente->getAlumnos();
        foreach($list as $alumno)
            {
                echo "<option id= ".$alumno->Matricula."> ".$alumno->Matricula." </opcion>";
            }
        ?>
        </select>
        <input type="text" id="nombreAlumno"/>
        <input name="" type="submit" value="" />
        <table id="excelTable">
            <tbody>
                    <th>Materia</th>
                    <th>Profesor</th>
                    <th>P1</th>
                    <th>P2</th>
                    <th>P3</th>
                    <th>P4</th>
                    <th>FIT</th>
                    <th>F1</th>
                    <th>F2</th>
                    <th>F3</th>
                    <th>F4</th>
                    <th>Total Faltas</th>
                    <th>Limite Faltas</th>
                
               </tbody>
        </table>
    </div>  
              
 </div>  

<script>
    entrada();
</script>                
                
</body>
</html>
